#!/usr/bin/python
from xml.etree import ElementTree

et = ElementTree.ElementTree(None, open('GPS.kml','r'))

er = et.getroot()

def displaytree(ele, lev = 0):
    print '|' + '---'*lev,
    try:
        print ele.tag.split('}')[1], ele.attrib or '',
    except:
        print ele.tag, ele.attrib or '',
    if ele.text:
        print ele.text.strip()
    else:
        print
    subs =  ele.getchildren()
    for e in subs:
        displaytree(e,lev+1)
#    print '|'+'---'*lev+ ele.tag + '---end'
        
#displaytree(er)

root = ElementTree.Element('kml')
root.attrib['xmlns'] = 'http://earth.google.com/kml/2.1'
document = ElementTree.Element('Document',)
document.text = '2525.2525,2525,3432.3422'
root.append(document)
place = ElementTree.Element('Placemark')


fromstr = ElementTree.fromstring('<kml xmlns="http://earth.google.com/kml/2.1"><Document>rueiqpuriepowquip</Document></kml>')

ElementTree.dump(root)


import chilkat

xml = chilkat.CkXml()

xml.LoadXmlFile('ori.xml')
newxml = chilkat.CkXml()
newxml.LoadXml('<user>nooooo</user>')
xml.AddChildTree(newxml)

xml.SaveXml('ori_formated.xml')
print xml.xml()
